<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<title>网站设置</title>
	{css href="/static/admin/component/layui/css/layui.css"}
	{css href="/static/admin/component/css/pearForm.css"}
	<style>
		.layui-form-label {
			width: auto;
		}
	</style>

</head>

<body class="pear-container">
	<div class="layui-card">
		<div class="layui-card-body">
			<div class="layui-row layui-col-space15">
				<div class="layui-col-md12">
					<form class="layui-card layui-form" lay-filter="webset">
						<div class="layui-card-body layui-row layui-col-space10">
							<div class="layui-col-md6">
								<label class="layui-form-label input-label">网站标题：</label>
								<input type="text" name="title" hover placeholder="请输入网站标题" autocomplete="off"
									class="layui-input" />
							</div>
							<div class="layui-col-md6">
								<label class="layui-form-label input-label">网站副标题：</label>
								<input type="text" name="subheading" hover placeholder="请输入网站副标题" autocomplete="off"
									class="layui-input" />
							</div>
							<div class="layui-col-md6">
								<label class="layui-form-label input-label">网站关键字：</label>
								<input type="text" name="keywords" hover placeholder="请输入网站关键字" autocomplete="off"
									class="layui-input" />
							</div>
							<div class="layui-col-md6">
								<label class="layui-form-label input-label">网站描述：</label>
								<input type="text" name="description" hover placeholder="请输入网站描述" autocomplete="off"
									class="layui-input" />
							</div>
							<div class="layui-col-md6">
								<label class="layui-form-label input-label">联系方式：</label>
								<input type="text" name="contact" hover placeholder="请输入QQ联系方式:656001878"
									autocomplete="off" class="layui-input" />
							</div>
							<div class="layui-col-md6">
								<label class="layui-form-label input-label">后台路径：</label>
								<input type="text" name="adminpath" hover placeholder="请输入后台路径：admin" autocomplete="off"
									class="layui-input" />
							</div>
							<div class="layui-col-md12">
								<label class="layui-form-label input-label">网站公告（支持HTML）</label>
								<textarea name="notice" placeholder="请填写网站公告信息" class="layui-textarea"></textarea>
							</div>
							<div class="layui-col-md12">
								<label class="layui-form-label input-label">底部版权（支持HTML）</label>
								<textarea name="copyright" placeholder="请填写底部版权信息" class="layui-textarea"></textarea>
							</div>
							<div class="layui-form-item">
								<div class="layui-input-block" style="margin-left: 0;">
									<button class="layui-btn" lay-submit lay-filter="webset">
										立即提交
									</button>
									<button type="reset" class="layui-btn layui-btn-primary">
										重置
									</button>
								</div>
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>

	{js href="/static/admin/component/layui/layui.js"}
	<script>
		layui.use(["layer", "form", 'jquery'], function () {
			var form = layui.form;
			var $ = layui.jquery
			form.render();
			// 提交
			form.on("submit(webset)", function (data) {
				var fd = new FormData();
				fd.append('adminpath', data.field.adminpath);
				fd.append('contact', data.field.contact);
				fd.append('copyright', data.field.copyright);
				fd.append('description', data.field.description);
				fd.append('keywords', data.field.keywords);
				fd.append('notice', data.field.notice);
				fd.append('subheading', data.field.subheading);
				fd.append('title', data.field.title);
				$.ajax({
					url: '/api/v1/webset/editinfo',
					data: fd,
					dataType: 'json',
					contentType: 'application/json',
					type: 'post',
					contentType: false, //不设置内容类型
					processData: false, //不处理数据
					beforeSend: function () {},
					success: function (result) {
						if (result.code) {
							layer.msg(result.msg, {
								icon: 1,
								time: 1000
							}, function () {

							});
						} else {
							layer.msg(result.msg, {
								icon: 2,
								time: 1000
							});
						}
					}
				})
				return false;
			});
			// 页面初始化
			$.get("/api/v1/webset/getinfo", function (data, status) {
				form.val('webset', data.data);
				form.render();
			});
		});
	</script>
</body>

</html>